function getUserInfo() {
    $.ajax({
        method: 'GET',
        url: '/my/userinfo',
        // headers 就是请求头配置对象
        success: function(res) {
            // console.log(res);
            if (!res.data) return;
            // 1 渲染头像和名字
            if (res.data.user_pic === null) {
                var firstWorld = (res.data.nickname || res.data.username).charAt(0).toUpperCase();
                $('.text_avatar').html(firstWorld).css("visibility", "visible")
                $('.layui-nav-img').hide();
            } else {
                $('.layui-nav-img').attr("src", res.data.user_pic).show();
                $('.text_avatar').hide();
            }
            $('.welcome').html('欢迎' + '&emsp;' + (res.data.nickname || res.data.username));
        }
    });
}
getUserInfo();
// 退出登录功能
$('.login_out').on('click', function() {
    layer.confirm('确认退出登录吗?', { icon: 3, title: '提示' }, function(index) {
        localStorage.removeItem('token');
        location.href = "/login.html";
        layer.close(index);
    });
});
$('.dian').click();